package com.sinochem.sales.auth.serivce;

import com.sinochem.sales.auth.util.UserDetailsImpl;
import com.sinochem.sales.common.entity.Result;
import com.sinochem.sales.admin.api.feign.UserService;
import com.sinochem.sales.admin.api.to.UserTO;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author xuan😴🐶🐱🐽🌺  <a href="zhangshixuanj@163.com">联系作者</a>
 * @version Revision:v1.0,Date: 2017/11/20 12:39
 * @project parent
 * @description 用户信息
 * @Modification Date: 2017/11/20 12:39  {填写修改说明}
 */
@Service("userDetailService")
public class UserDetailServiceImpl implements UserDetailsService {

    @Resource
    private UserService userService;

    @Override
    public UserDetailsImpl loadUserByUsername(String username) throws UsernameNotFoundException {
        Result<UserTO> result = userService.findUserByUserName(username);
        return new UserDetailsImpl(result.getData());
    }
}
